package cn.driver.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.driver.domain.Car;
import cn.driver.domain.Student;
import cn.driver.mapper.CarMapper;
import cn.driver.utils.MD5Util;
import cn.driver.utils.MyException;

@Service 
public class CarService {
	@Autowired
	private CarMapper carMapper;
	/**
	 * 新增车辆
	 * @param car_id
	 * @param teacher
	 * @param remarks
	 */
	public void regist(String car_id, String teacher, String remarks) throws MyException {
		//校验学员是否被注册
		Car s=carMapper.selectCar(car_id);
		if(s!=null){
			throw new MyException("该用户已注册！请勿重复注册");
		}
		carMapper.registCar(car_id,teacher, remarks);

	}
	/**
	 * 遍历汽车
	 * @return
	 */
	public List<Car> carInfo() {

		return carMapper.carInfo();
	}
	/**
	 * 检索
	 * @param info
	 * @return
	 */
	public List<Car> carSearch(String Info) {
		// TODO Auto-generated method stub
		return carMapper.searchInfo(Info);
	}
	/**
	 * 删除车辆
	 * @param car_id
	 * @throws MyException
	 */
	public void deleteCar(String car_id) throws MyException {
		carMapper.deleteCar(car_id);		
	}
	/**
	 * 查重
	 * @param car_id
	 * @return
	 */
	public Car selectCar(String car_id) {
		// TODO Auto-generated method stub
		return carMapper.selectCar(car_id);
	}
	/**
	 * 修改信息
	 * @param car_id
	 * @param teacher
	 * @param remarks
	 */
	public void updateCar(String car_id, String teacher, String remarks,String info) {
		carMapper.updateCar(car_id,teacher,remarks,info);
	}
	
}
